$(function() {


    const pros1 = new Promise((resolve, reject) => {
        $.ajax(`${baseurl}/categories/count`, {
            success: function(res) {
                console.log(res);
                resolve(res)
            },
            error: function(err) {
                console.log('获取分类数量失败');
                reject(err)
            }
        })
    })

    const pros2 = new Promise((resolve, reject) => {
        $.ajax(`${baseurl}/posts/count`, {
            success: function(res) {
                console.log(res);
                resolve(res)
            },
            error: function(err) {
                reject(err)
            }

        })
    })

    const pros3 = new Promise((resolve, reject) => {
        $.ajax(`${baseurl}/comments/count`, {
            success: function(res) {
                resolve(res)
            },
            error: function(err) {
                reject(err)
            }

        })
    })


    Promise.all([pros1, pros2, pros3]).then(res => {
        let tempobj = {}
        res.forEach(item => {
            for (let key in item) {
                tempobj[key] = item[key]
            }
        })
        const newhtml = template('list-groupid', tempobj)
        $('.list-group').html(newhtml)
    }).catch(err => {
        console.log(err);
    })
})